package com.hmall.controller;


import com.hdmall.business.common.common.ServerResponse;
import com.hmall.service.ConstantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Calendar;

/**
 * @Author  zhoutao
 */
@RestController
@RequestMapping("/cons/")
@CrossOrigin(origins = "http://localhost:8088", maxAge = 3600)
@Api(value = "常量", description = "获取常量API")
public class ConstantController {

    @Autowired
    ConstantService constantService;

    public static String testOrderUrl = "http://47.98.169.251:9092";

    public static String testManageUrl = "http://47.98.169.251:9093";

    public static String testHCloudUrl = "http://47.98.167.99:9999";

    public static String devHCloudUrl = "http://47.98.213.218:9999";

//    public static String indexUrl = "http://47.98.169.251:8081";

    public static String devOrderUrl = "http://47.98.171.71:9092";

    public static String devManageUrl = "http://47.98.171.71:9093";



    @GetMapping("getUrl")
    @ApiOperation(value = "获取各种资料的url", notes = "物流价格和物流公司价目表（图片）——logisImg  |" +
            " 物流价格和物流公司价目表（word）——logisWord )  |" + "企业营业执照模板（图片）——licenseImg  |" +
            "一般纳税人资质证书模板（图片）——taxCertImg  |" + "企业授权书模板已盖章（图片）——authImg  |" +
            "企业授权书模板未盖章模板（图片）——authNoImg  |" + "企业授权书未盖章模板（word）——authNoWord  |" +
            "自提委托书（图片）——selfProxyImg  |" + "用户注册协议（html）——regProtocol  |" + "月度订单计划评审(html) ——monthPlanReview"
     )
    public String getUrl(String type){

        return constantService.getUrl(type);
    }

    @GetMapping("getUrlNew")
    @ApiOperation(value = "获取各种资料的url", notes = "物流价格和物流公司价目表（图片）——logisImg  |" +
            " 物流价格和物流公司价目表（word）——logisWord )  |" + "企业营业执照模板（图片）——licenseImg  |" +
            "一般纳税人资质证书模板（图片）——taxCertImg  |" + "企业授权书模板已盖章（图片）——authImg  |" +
            "企业授权书模板未盖章模板（图片）——authNoImg  |" + "企业授权书未盖章模板（word）——authNoWord  |" +
            "自提委托书（图片）——selfProxyImg  |" + "用户注册协议（html）——regProtocol  |" + "月度订单计划评审(html) ——monthPlanReview"
    )
    public ServerResponse<String> getUrlNew(String type){

        return ServerResponse.createBySuccess(constantService.getUrl(type));
    }


    @GetMapping("getServerTime")
    @ApiOperation(value = "得到服务器时间", notes = "返回时间戳")
    public ServerResponse getServerTime(){

        Calendar calendar = Calendar.getInstance();
        return ServerResponse.createBySuccess(calendar.getTime());
    }

    @GetMapping("getIOSVersion")
    @ApiOperation(value = "IOS得到版本号", notes = "type (mall/dealer)返回参数说明：value版本号，unit布尔值")
    public ServerResponse getIOSVersion(String type){

        return constantService.getIOSVersion(type);
    }

    @PostMapping("setIOSVersion")
    @ApiOperation(value = "IOS设置版本号", notes = "type(mall/dealer)传入参数说明：version版本号,check 布尔值")
    public ServerResponse setIOSVersion(String type, String version, String check){

        return constantService.setIOSVersion(type, version, check);
    }




}
